package cn.chuanw.core.storage.config;


import cn.chuanw.core.storage.LocalStorage;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(cn.chuanw.core.storage.config.StorageProperties.class)
public class StorageAutoConfiguration {

    private final cn.chuanw.core.storage.config.StorageProperties properties;

    public StorageAutoConfiguration(cn.chuanw.core.storage.config.StorageProperties properties) {
        this.properties = properties;
    }


    @Bean
    public LocalStorage localStorage() {
        LocalStorage localStorage = new LocalStorage();
        cn.chuanw.core.storage.config.StorageProperties.Local local = this.properties.getLocal();
        localStorage.setAddress(local.getAddress());
        localStorage.setStoragePath(local.getStoragePath());
        localStorage.setManagerAddress(local.getManagerAddress());
//        localStorage.setManagerStoragePath(local.getManagerStoragePath());
        return localStorage;
    }
}
